package com.itcast.plane.modoule.planes.controller;

import com.itcast.plane.modoule.company.domain.Company;
import com.itcast.plane.modoule.company.dto.CompanyCreatDTO;
import com.itcast.plane.modoule.company.service.CompanyService;
import com.itcast.plane.modoule.planes.domain.Planes;
import com.itcast.plane.modoule.planes.dto.PlanesCreatDTO;
import com.itcast.plane.modoule.planes.service.PlanesService;
import com.itcast.plane.util.JsonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/planes")
public class PlanesController {

    @Resource
    private PlanesService planesService;

    @PostMapping("/add")
    public JsonResult addPlanes(@RequestBody PlanesCreatDTO creatDTO){
        return planesService.addPlanes(creatDTO);
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult deletePlanes(@PathVariable int id){
        return planesService.deletePlanes(id);
    }

    @PutMapping("/edit")
    public JsonResult editPlanes(@RequestBody Planes planes){
        return planesService.editPlanes(planes);
    }

    @GetMapping("/getpage")
    public JsonResult getPage(@RequestParam int pages){
        return planesService.getPage(pages);
    }

    @GetMapping("/getall")
    public JsonResult getAll(){
        return planesService.getAll();
    }
}
